package com.calsoft.Hops_Mobile_Tablet.util;
/*
 * User: Minh Diep
 * Date: 7/3/13
 * Time: 10:52 AM
 */

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPrefs {

    public static final String ID = "com.calsoft.hops.mobile.shared.prefs";
    public static final String CURRENT_PAGE = "com.calsoft.hops.mobile.shared.prefs.current.page";
    public static final String CURRENT_SUB_PAGE = "com.calsoft.hops.mobile.shared.prefs.current.sub.page";
    public static final String CURRENT_LOCATION = "com.calsoft.hops.mobilet.shared.prefs.current.location";
    public static final String CURRENT_COUNTRY = "com.calsoft.hops.mobilet.shared.prefs.current.country";
    public static final String CATEGORY_FILTER = "com.calsoft.hops.mobile.category.filter.";
    public static final String CURRENT_LAND_SERVICE_CODE = "com.calsoft.hops.mobile.shared.prefs.current.land.service.code";

    private SharedPreferences sPrefs;
    private SharedPreferences.Editor sPrefsEditor;

    public SharedPrefs(Context context){
        sPrefs = context.getSharedPreferences(ID, 0);
        sPrefsEditor = sPrefs.edit();
    }

    public void commit(){
        sPrefsEditor.commit();
    }

    public void clear(){
        sPrefsEditor.clear();
        sPrefsEditor.commit();
    }

    public void putString (String key, String value){
        sPrefsEditor.putString(key, value);
        sPrefsEditor.commit();
    }

    public String getString (String key, String defValue){
        return sPrefs.getString(key, defValue);
    }

    public void putInt (String key, int value){
        sPrefsEditor.putInt(key, value);
        sPrefsEditor.commit();
    }

    public int getInt (String key, int defValue){
        return sPrefs.getInt(key, defValue);
    }

    public void putBoolean (String key, boolean value){
        sPrefsEditor.putBoolean(key, value);
        sPrefsEditor.commit();
    }

    public boolean getBoolean (String key, boolean defValue){
        return sPrefs.getBoolean(key, defValue);
    }

    public void onlyPutBoolean (String key, boolean value){
        sPrefsEditor.putBoolean(key, value);
    }
}
